﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using V5_Common;
using V5_BLL;
using V5_Model;

namespace V5_EShop.Modules.Product {
    /// <summary>
    /// ProductComment 的摘要说明
    /// </summary>
    public class ProductComment : IHttpHandler {
        HttpContext context;
        public void ProcessRequest(HttpContext context) {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }

        public bool IsReusable {
            get {
                return false;
            }
        }

        private void ReProductComment() {
            int pid = InputHelper.SetNumber(context.Request["lhpid"]);
            string Action = InputHelper.SetString(context.Request["laction"]);
            string s1 = InputHelper.SetString(context.Request["txtpCommentContent"]);
            string s2 = InputHelper.SetString(context.Request["txtpCommentEmail"]);
            string s3 = InputHelper.SetString(context.Request["txtpCommentUserName"]);
            string s4 = InputHelper.SetString(context.Request["ddlpmost"]);

            // if (Action == "savecomment")
            {
                BLLProductComment bll = new BLLProductComment();
                ModelProductComment model = new ModelProductComment();
                int ID = bll.GetMaxId();
                string CommentContent = s1;
                string CommentName = s3;
                string CommentEmail = s2;
                string CommentIP = HttpsHelper.GetIP;
                string ProductName = new BLLProduct().GetModel(pid, true).ProductName;
                DateTime AddDateTime = DateTime.Now;
                string ReplyComment = "";
                string ReplyName = "";
                int Pmost = InputHelper.SetNumber(s4);

                model.ID = ID;
                model.CommentContent = CommentContent;
                model.CommentName = CommentName;
                model.CommentEmail = CommentEmail;
                model.CommentIP = CommentIP;
                model.ProductName = ProductName;
                model.ProductID = pid;
                model.AddDateTime = AddDateTime;
                model.ReplyComment = ReplyComment;
                model.ReplyName = ReplyName;
                model.Pmost = Pmost;

                bll.Add(model);

                JsHelper.AlertAndRedirect("发布成功!", "/product-details-" + pid + ".aspx");
            }
        }
    }
}